package com.info.zhiduoduo.repository.mapper.maker;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.info.zhiduoduo.repository.dto.account.MakerAccountFlowDto;
import com.info.zhiduoduo.repository.entity.maker.MakerAccountflow;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 创客账户流水(收入支出明细) Mapper 接口
 * </p>
 *
 * @author bob
 * @since 2018-12-23
 */
public interface MakerAccountflowMapper extends BaseMapper<MakerAccountflow> {

	@Select(" select uaf.*,us.username,cp.compname,ac.realname " +
			" from zdd_maker_accountflow uaf " +
			" join zdd_maker_studio us on us.userid = uaf.userid " +
			" left join zdd_company cp on cp.compid = uaf.compid " +
			" left join zdd_maker_account ac on ac.userid=uaf.userid" +
			" where if(#{flowtype}=0,1=1,flowtype=#{flowtype}) " +
			" and uaf.createtime between #{startDate} and #{endDate} " +
			" and concat(us.username,IFNULL(uaf.flowname,''),IFNUll(ac.realname,'')) like '%${name}%' " +
			" order by uaf.id desc ")
	List<MakerAccountFlowDto> getAccountFlowList(@Param("name") String name, @Param("flowtype") int flowtype, @Param("startDate") Date startDate, @Param("endDate") Date endDate);

}
